package user_assets

import (
	"context"

	"gitee.com/liuxuezhan/ar-platform/base-common/headInfo"
	"gitee.com/liuxuezhan/ar-platform/rpc-client/assetsClient/rpc"

	"gitee.com/liuxuezhan/ar-platform/assets-api/internal/svc"
	"gitee.com/liuxuezhan/ar-platform/assets-api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserDelBankInfoLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

// user-assets
func NewUserDelBankInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserDelBankInfoLogic {
	return &UserDelBankInfoLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UserDelBankInfoLogic) UserDelBankInfo(req *types.UserDelBankInfoRequest) (resp *types.UserDelBankInfoResponse, err error) {
	info, err := l.svcCtx.AssetsRpc.UserChannel.UserBankDelete(l.ctx, &rpc.UserBankDelRequest{
		Id:     req.ID,
		UserId: headInfo.GetTokenUid(l.ctx),
	})
	if err != nil {
		return &types.UserDelBankInfoResponse{
			IsDel: false,
		}, err
	}
	return &types.UserDelBankInfoResponse{
		IsDel: info.IsDel,
	}, nil
}
